
//增加合同
function addContract(id, contract_number, contract_name, contract_day, Client_name, contract_opportunity, contract_amount, contract_content, contract_fj, contract_state, contract_createdDate, contract_Player, contract_conftime,
    payment_day, payment_period, payment_method, payment_amount, isOverdue, bank, account, overdue, note) {

    db.contract.push({
        id, contract_number, contract_name, contract_day, Client_name, contract_opportunity, contract_amount, contract_content, contract_fj, contract_state, contract_createdDate, contract_Player, contract_conftime,
        payment_day, payment_period, payment_method, payment_amount, isOverdue, bank, account, overdue, note
    });

}
//删除合同
function delContractbyid(id) {
    try {
        for (let i = 0; i < db.contract.length; i++) {
            if (db.contract[i].id == id) {
                db.contract.splice(i, 1);
                i--;
                break;
            }
        }
        // asyncLocalStory("contract");
        asyncLocalStory();
        return true;
    }
    catch (e) {
        return false;
    }
}






function huoqvkhid(id) {
    try {
        for (let i = 0; i < db.connection.length; i++) {
            if (db.connection[i].id == id) {
                db.connection.splice(i, 1);
                break;
            }
        }
        // asyncLocalStory("connection");
        asyncLocalStory();
        return true;
    }
    catch (e) {
        return false;
    }
}





//分页
function displayContractData() {//初始化合同记录的数据
    let table = document.getElementById('table1');
    let ul = document.getElementById('pagination');
    let page_number = 5; //单页浏览的条数
    let Total_pages = 1; //页数
    let liAll; //页码按钮下标为 1到length-2是页数 0和length-1为上一页和下一页
    let pre; //上一页
    let next; //下一页
    let tbody = $('#DataShow');
    contract.forEach(function (item, i) {
        //当下标小于页面展示的数据
        if (i < page_number) {
            let tr = document.createElement("tr");
            if (db.contract[i].contract_state == "已保存" || db.contract[i].contract_state == "已驳回" || db.contract[i].contract_state == "") {
                tr.innerHTML = `
            <td name="id">${i + 1}</td>
            <td name="contract_number">${db.contract[i].contract_number}</td>
            <td name="contract_name">${db.contract[i].contract_name}</td>
            <td name="Client_name">${db.contract[i].Client_name}</td>
            <td name="contract_day">${db.contract[i].contract_day}</td>
            <td name="contract_amount">${db.contract[i].contract_amount}</td>
            <td name="payment_amount">${db.contract[i].payment_amount}</td>
            <td name="contract_state">${db.contract[i].contract_state}</td>
            <td name="contract_createdDate">${db.contract[i].contract_createdDate}</td>
            <td>
                <button class="btnModify btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                <button class="btnView btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                <button class="btnDelete btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
            </td>
        `
                tbody.append(tr);
            }
            else if (db.contract[i].contract_state == "待审核" || db.contract[i].contract_state == "已审核") {
                tr.innerHTML = `
                <td name="id">${i + 1}</td>
                <td name="contract_number">${db.contract[i].contract_number}</td>
                <td name="contract_name">${db.contract[i].contract_name}</td>
                <td name="Client_name">${db.contract[i].Client_name}</td>
                <td name="contract_day">${db.contract[i].contract_day}</td>
                <td name="contract_amount">${db.contract[i].contract_amount}</td>
                <td name="payment_amount">${db.contract[i].payment_amount}</td>
                <td name="contract_state">${db.contract[i].contract_state}</td>
                <td name="contract_createdDate">${db.contract[i].contract_createdDate}</td>
                <td>

                    <button class="btnView btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>

                </td>
            `
                tbody.append(tr);
            }
            else {
                tr.innerHTML = `
                <td name="id">${i + 1}</td>
                <td name="contract_number">${db.contract[i].contract_number}</td>
                <td name="contract_name">${db.contract[i].contract_name}</td>
                <td name="Client_name">${db.contract[i].Client_name}</td>
                <td name="contract_day">${db.contract[i].contract_day}</td>
                <td name="contract_amount">${db.contract[i].contract_amount}</td>
                <td name="payment_amount">${db.contract[i].payment_amount}</td>
                <td name="contract_state">${db.contract[i].contract_state}</td>
                <td name="contract_createdDate">${db.contract[i].contract_createdDate}</td>
                <td>
                    <button class="btnModify btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                    <button class="btnView btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                    <button class="btnDelete btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                </td>
            `
                tbody.append(tr);
            }

        }
    })
    let len = contract.length; //记录总条数
    // console.log(len);
    let TotalArr = len % page_number == 0 ? len / page_number : len / page_number + 1; //页数

    ul.innerHTML += `
        <li id="pre">
            <a href="#">
                <span aria-hidden="true">&lt;</span>
            </a>
        </li>
    `
    //根据页面数量来创建下标
    for (let i = 1; i <= TotalArr; i++) {
        ul.innerHTML += `
        <li id="${i}"><a href="#javascript">${i}</a></li>
    `
    }
    ul.innerHTML += `
        <li id="next">
            <a href="#javascript"  aria-label="Next">
                <span aria-hidden="true">&gt;</span>
            </a>    
        </li>
    `
    liAll = document.querySelectorAll('#pagination li');
    liAll[1].childNodes[0].style.color = '#fff' //初识第一页页码是红的
    liAll[1].childNodes[0].style.backgroundColor = '#44B096'
    let pageThis = 1; //当前是第几页
    for (let i = 1; i < liAll.length - 1; i++) { //0和length-1是上一页下一页
        liAll[i].onclick = function () {
            for (let j = 1; j < liAll.length - 1; j++) {
                liAll[j].childNodes[0].style.color = '#ccc';
                liAll[j].childNodes[0].style.backgroundColor = '#fff'
            }
            pageThis = this.id;
            // console.log(pageThis);
            liAll[pageThis].childNodes[0].style.color = '#fff';
            liAll[pageThis].childNodes[0].style.backgroundColor = '#44B096'

            let start;//当前数据的起始下标
            let end;//当前数据的结束下标

            if (pageThis != 1) {
                start = (pageThis - 1) * page_number;
                end = start + page_number - 1;
                if (end > db.contract.length - 1) {//如果当页面数据结束值大于总数据条数下标的值则赋值为总数据条数最大下标值。
                    end = db.contract.length - 1
                }
            }
            else {
                start = 0;
                end = page_number - 1;
            }
            tbody.html('');//清空原页面

            db.contract.forEach(function (item, i) {
                if (i >= start && i <= end) {
                    let tr = document.createElement('tr');
                    if (db.contract[i].contract_state == "已保存" || db.contract[i].contract_state == "已驳回" || db.contract[i].contract_state == "") {
                        tr.innerHTML = `
                    <td name="id">${i + 1}</td>
                    <td name="contract_number">${db.contract[i].contract_number}</td>
                    <td name="contract_name">${db.contract[i].contract_name}</td>
                    <td name="Client_name">${db.contract[i].Client_name}</td>
                    <td name="contract_day">${db.contract[i].contract_day}</td>
                    <td name="contract_amount">${db.contract[i].contract_amount}</td>
                    <td name="payment_amount">${db.contract[i].payment_amount}</td>
                    <td name="contract_state">${db.contract[i].contract_state}</td>
                    <td name="contract_createdDate">${db.contract[i].contract_createdDate}</td>
                    <td>
                        <button class="btnModify btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                        <button class="btnView btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                        <button class="btnDelete btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                    </td>
                `
                        tbody.append(tr);
                    }
                    else if (db.contract[i].contract_state == "待审核" || db.contract[i].contract_state == "已审核") {
                        tr.innerHTML = `
                        <td name="id">${i + 1}</td>
                        <td name="contract_number">${db.contract[i].contract_number}</td>
                        <td name="contract_name">${db.contract[i].contract_name}</td>
                        <td name="Client_name">${db.contract[i].Client_name}</td>
                        <td name="contract_day">${db.contract[i].contract_day}</td>
                        <td name="contract_amount">${db.contract[i].contract_amount}</td>
                        <td name="payment_amount">${db.contract[i].payment_amount}</td>
                        <td name="contract_state">${db.contract[i].contract_state}</td>
                        <td name="contract_createdDate">${db.contract[i].contract_createdDate}</td>
                        <td>
        
                            <button class="btnView btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
        
                        </td>
                    `
                        tbody.append(tr);
                    }
                    else {
                        tr.innerHTML = `
                        <td name="id">${i + 1}</td>
                        <td name="contract_number">${db.contract[i].contract_number}</td>
                        <td name="contract_name">${db.contract[i].contract_name}</td>
                        <td name="Client_name">${db.contract[i].Client_name}</td>
                        <td name="contract_day">${db.contract[i].contract_day}</td>
                        <td name="contract_amount">${db.contract[i].contract_amount}</td>
                        <td name="payment_amount">${db.contract[i].payment_amount}</td>
                        <td name="contract_state">${db.contract[i].contract_state}</td>
                        <td name="contract_createdDate">${db.contract[i].contract_createdDate}</td>
                        <td>
                            <button class="btnModify btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                            <button class="btnView btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                            <button class="btnDelete btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                        </td>
                    `
                        tbody.append(tr);
                    }
                }
            })
        }
    }

    pre = document.getElementById('pre');//上一页
    next = document.getElementById('next');//下一页

    pre.onclick = function (e) {
        e.preventDefault();
        if (pageThis != 1) { //当前页数不等于1时执行上一页
            pageThis--;
            for (let j = 1; j < liAll.length - 1; j++) {
                liAll[j].childNodes[0].style.color = "#ccc"
                liAll[j].childNodes[0].style.backgroundColor = "#fff"
            }
            liAll[pageThis].childNodes[0].style.color = "#fff";
            liAll[pageThis].childNodes[0].style.backgroundColor = "#44B096"
            let start;
            let end;
            if (pageThis != 1) {
                start = (pageThis - 1) * page_number;
                end = start + page_number - 1;
                if (end > db.contract.length - 1) {
                    end = db.contract.length - 1;
                }
            } else {
                start = 0;
                end = page_number - 1;
            }

            tbody.html('');//清空原页面
            db.contract.forEach(function (item, i) {
                if (i >= start && i <= end) {
                    let tr = document.createElement("tr");
                    if (db.contract[i].contract_state == "已保存" || db.contract[i].contract_state == "已驳回" || db.contract[i].contract_state == "") {
                        tr.innerHTML = `
                    <td name="id">${i + 1}</td>
                    <td name="contract_number">${db.contract[i].contract_number}</td>
                    <td name="contract_name">${db.contract[i].contract_name}</td>
                    <td name="Client_name">${db.contract[i].Client_name}</td>
                    <td name="contract_day">${db.contract[i].contract_day}</td>
                    <td name="contract_amount">${db.contract[i].contract_amount}</td>
                    <td name="payment_amount">${db.contract[i].payment_amount}</td>
                    <td name="contract_state">${db.contract[i].contract_state}</td>
                    <td name="contract_createdDate">${db.contract[i].contract_createdDate}</td>
                    <td>
                        <button class="btnModify btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                        <button class="btnView btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                        <button class="btnDelete btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                    </td>
                `
                        tbody.append(tr);
                    }
                    else if (db.contract[i].contract_state == "待审核" || db.contract[i].contract_state == "已审核") {
                        tr.innerHTML = `
                        <td name="id">${i + 1}</td>
                        <td name="contract_number">${db.contract[i].contract_number}</td>
                        <td name="contract_name">${db.contract[i].contract_name}</td>
                        <td name="Client_name">${db.contract[i].Client_name}</td>
                        <td name="contract_day">${db.contract[i].contract_day}</td>
                        <td name="contract_amount">${db.contract[i].contract_amount}</td>
                        <td name="payment_amount">${db.contract[i].payment_amount}</td>
                        <td name="contract_state">${db.contract[i].contract_state}</td>
                        <td name="contract_createdDate">${db.contract[i].contract_createdDate}</td>
                        <td>
        
                            <button class="btnView btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
        
                        </td>
                    `
                        tbody.append(tr);
                    }
                    else {
                        tr.innerHTML = `
                        <td name="id">${i + 1}</td>
                        <td name="contract_number">${db.contract[i].contract_number}</td>
                        <td name="contract_name">${db.contract[i].contract_name}</td>
                        <td name="Client_name">${db.contract[i].Client_name}</td>
                        <td name="contract_day">${db.contract[i].contract_day}</td>
                        <td name="contract_amount">${db.contract[i].contract_amount}</td>
                        <td name="payment_amount">${db.contract[i].payment_amount}</td>
                        <td name="contract_state">${db.contract[i].contract_state}</td>
                        <td name="contract_createdDate">${db.contract[i].contract_createdDate}</td>
                        <td>
                            <button class="btnModify btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                            <button class="btnView btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                            <button class="btnDelete btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                        </td>
                    `
                        tbody.append(tr);
                    }
                }
            })
        }
    }

    next.onclick = function (e) {
        e.preventDefault();
        if (pageThis < liAll.length - 2) { //当前页数小于最后一页则执行下一页
            pageThis++;
            for (var j = 1; j < liAll.length - 1; j++) {
                liAll[j].childNodes[0].style.color = "#ccc"
                liAll[j].childNodes[0].style.backgroundColor = "#fff"
            }
            liAll[pageThis].childNodes[0].style.color = "#fff";
            liAll[pageThis].childNodes[0].style.backgroundColor = "#44B096"
            let start;
            let end;
            if (pageThis != 1) {
                start = (pageThis - 1) * page_number;
                end = start + page_number - 1;
                if (end > db.contract.length - 1) {
                    end = db.contract.length - 1;
                }
            } else {
                start = 0;
                end = page_number - 1;
            }

            tbody.html('');//清空原页面
            db.contract.forEach(function (item, i) {
                if (i >= start && i <= end) {
                    var tr = document.createElement("tr");
                    if (db.contract[i].contract_state == "已保存" || db.contract[i].contract_state == "已驳回" || db.contract[i].contract_state == "") {
                        tr.innerHTML = `
                    <td name="id">${i + 1}</td>
                    <td name="contract_number">${db.contract[i].contract_number}</td>
                    <td name="contract_name">${db.contract[i].contract_name}</td>
                    <td name="Client_name">${db.contract[i].Client_name}</td>
                    <td name="contract_day">${db.contract[i].contract_day}</td>
                    <td name="contract_amount">${db.contract[i].contract_amount}</td>
                    <td name="payment_amount">${db.contract[i].payment_amount}</td>
                    <td name="contract_state">${db.contract[i].contract_state}</td>
                    <td name="contract_createdDate">${db.contract[i].contract_createdDate}</td>
                    <td>
                        <button class="btnModify btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                        <button class="btnView btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                        <button class="btnDelete btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                    </td>
                `
                        tbody.append(tr);
                    }
                    else if (db.contract[i].contract_state == "待审核" || db.contract[i].contract_state == "已审核") {
                        tr.innerHTML = `
                        <td name="id">${i + 1}</td>
                        <td name="contract_number">${db.contract[i].contract_number}</td>
                        <td name="contract_name">${db.contract[i].contract_name}</td>
                        <td name="Client_name">${db.contract[i].Client_name}</td>
                        <td name="contract_day">${db.contract[i].contract_day}</td>
                        <td name="contract_amount">${db.contract[i].contract_amount}</td>
                        <td name="payment_amount">${db.contract[i].payment_amount}</td>
                        <td name="contract_state">${db.contract[i].contract_state}</td>
                        <td name="contract_createdDate">${db.contract[i].contract_createdDate}</td>
                        <td>
        
                            <button class="btnView btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
        
                        </td>
                    `
                        tbody.append(tr);
                    }
                    else {
                        tr.innerHTML = `
                        <td name="id">${i + 1}</td>
                        <td name="contract_number">${db.contract[i].contract_number}</td>
                        <td name="contract_name">${db.contract[i].contract_name}</td>
                        <td name="Client_name">${db.contract[i].Client_name}</td>
                        <td name="contract_day">${db.contract[i].contract_day}</td>
                        <td name="contract_amount">${db.contract[i].contract_amount}</td>
                        <td name="payment_amount">${db.contract[i].payment_amount}</td>
                        <td name="contract_state">${db.contract[i].contract_state}</td>
                        <td name="contract_createdDate">${db.contract[i].contract_createdDate}</td>
                        <td>
                            <button class="btnModify btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                            <button class="btnView btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                            <button class="btnDelete btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                        </td>
                    `
                        tbody.append(tr);
                    }
                }
            })
        }
    }
}


//回款分页
function displayContractData2() {//初始化合同记录的数据
    let table = document.getElementById('table0');
    let ul = document.getElementById('pagination0');
    let page_number = 5; //单页浏览的条数
    let Total_pages = 1; //页数
    let liAll; //页码按钮下标为 1到length-2是页数 0和length-1为上一页和下一页
    let pre; //上一页
    let next; //下一页
    let tbody = $('#DataShow0');
    contract.forEach(function (item, i) {
        //当下标小于页面展示的数据
        if (i < page_number) {
            let tr = document.createElement("tr");
            if (db.contract[i].contract_state == "已保存" || db.contract[i].contract_state == "已驳回" || db.contract[i].contract_state == "") {
                tr.innerHTML = `
            <td>${i + 1}</td>
            <td>${db.contract[i].id}</td>
            <td>${db.contract[i].Client_name}</td>
            <td>${db.contract[i].payment_day}</td>
            <td>${db.contract[i].contract_number}</td>
            <td>${db.contract[i].payment_period}</td>
            <td>${db.contract[i].payment_method}</td>
            <td>${db.contract[i].isOverdue}</td>
            <td >${db.contract[i].contract_state}</td>
            <td >${db.contract[i].contract_createdDate}</td>
            <td>
                <button class="btnModify1 btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                <button class="btnView1 btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                <button class="btnDelete1 btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
            </td>
        `;
                tbody.append(tr);
            }
            else if (db.contract[i].contract_state == "待审核" || db.contract[i].contract_state == "已审核") {
                tr.innerHTML = `
                <td>${i + 1}</td>
                <td>${db.contract[i].id}</td>
                <td>${db.contract[i].Client_name}</td>
                <td>${db.contract[i].payment_day}</td>
                <td>${db.contract[i].contract_number}</td>
                <td>${db.contract[i].payment_period}</td>
                <td>${db.contract[i].payment_method}</td>
                <td>${db.contract[i].isOverdue}</td>
                <td >${db.contract[i].contract_state}</td>
                <td >${db.contract[i].contract_createdDate}</td>
                <td>

                    <button class="btnView1 btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>

                </td>
            `
                tbody.append(tr);
            }
            else {
                tr.innerHTML = `
                <td>${i + 1}</td>
                <td>${db.contract[i].id}</td>
                <td>${db.contract[i].Client_name}</td>
                <td>${db.contract[i].payment_day}</td>
                <td>${db.contract[i].contract_number}</td>
                <td>${db.contract[i].payment_period}</td>
                <td>${db.contract[i].payment_method}</td>
                <td>${db.contract[i].isOverdue}</td>
                <td >${db.contract[i].contract_state}</td>
                <td >${db.contract[i].contract_createdDate}</td>
                <td>
                    <button class="btnModify1 btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                    <button class="btnView1 btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                    <button class="btnDelete1 btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                </td>
            `
                tbody.append(tr);
            }

        }
    })
    let len = contract.length; //记录总条数
    // console.log(len);
    let TotalArr = len % page_number == 0 ? len / page_number : len / page_number + 1; //页数

    ul.innerHTML += `
        <li id="pre">
            <a href="#">
                <span aria-hidden="true">&lt;</span>
            </a>
        </li>
    `
    //根据页面数量来创建下标
    for (let i = 1; i <= TotalArr; i++) {
        ul.innerHTML += `
        <li id="${i}"><a href="#javascript">${i}</a></li>
    `
    }
    ul.innerHTML += `
        <li id="next">
            <a href="#javascript"  aria-label="Next">
                <span aria-hidden="true">&gt;</span>
            </a>    
        </li>
    `
    liAll = document.querySelectorAll('#pagination0 li');
    liAll[1].childNodes[0].style.color = '#fff' //初识第一页页码是红的
    liAll[1].childNodes[0].style.backgroundColor = '#44B096'
    let pageThis = 1; //当前是第几页
    for (let i = 1; i < liAll.length - 1; i++) { //0和length-1是上一页下一页
        liAll[i].onclick = function () {
            for (let j = 1; j < liAll.length - 1; j++) {
                liAll[j].childNodes[0].style.color = '#ccc';
                liAll[j].childNodes[0].style.backgroundColor = '#fff'
            }
            pageThis = this.id;
            // console.log(pageThis);
            liAll[pageThis].childNodes[0].style.color = '#fff';
            liAll[pageThis].childNodes[0].style.backgroundColor = '#44B096'

            let start;//当前数据的起始下标
            let end;//当前数据的结束下标

            if (pageThis != 1) {
                start = (pageThis - 1) * page_number;
                end = start + page_number - 1;
                if (end > db.contract.length - 1) {//如果当页面数据结束值大于总数据条数下标的值则赋值为总数据条数最大下标值。
                    end = db.contract.length - 1
                }
            }
            else {
                start = 0;
                end = page_number - 1;
            }
            tbody.html('');//清空原页面

            db.contract.forEach(function (item, i) {
                if (i >= start && i <= end) {
                    let tr = document.createElement('tr');
                    if (db.contract[i].contract_state == "已保存" || db.contract[i].contract_state == "已驳回" || db.contract[i].contract_state == "") {
                        tr.innerHTML = `
                        <td>${i + 1}</td>
                        <td>${db.contract[i].id}</td>
                        <td>${db.contract[i].Client_name}</td>
                        <td>${db.contract[i].payment_day}</td>
                        <td>${db.contract[i].contract_number}</td>
                        <td>${db.contract[i].payment_period}</td>
                        <td>${db.contract[i].payment_method}</td>
                        <td>${db.contract[i].isOverdue}</td>
                        <td >${db.contract[i].contract_state}</td>
                        <td >${db.contract[i].contract_createdDate}</td>
                    <td>
                        <button class="btnModify1 btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                        <button class="btnView1 btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                        <button class="btnDelete1 btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                    </td>
                `
                        tbody.append(tr);
                    }
                    else if (db.contract[i].contract_state == "待审核" || db.contract[i].contract_state == "已审核") {
                        tr.innerHTML = `
                        <td>${i + 1}</td>
                        <td>${db.contract[i].id}</td>
                        <td>${db.contract[i].Client_name}</td>
                        <td>${db.contract[i].payment_day}</td>
                        <td>${db.contract[i].contract_number}</td>
                        <td>${db.contract[i].payment_period}</td>
                        <td>${db.contract[i].payment_method}</td>
                        <td>${db.contract[i].isOverdue}</td>
                        <td >${db.contract[i].contract_state}</td>
                        <td >${db.contract[i].contract_createdDate}</td>
                        <td>
        
                            <button class="btnView1 btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
        
                        </td>
                    `
                        tbody.append(tr);
                    }
                    else {
                        tr.innerHTML = `
                        <td>${i + 1}</td>
                        <td>${db.contract[i].id}</td>
                        <td>${db.contract[i].Client_name}</td>
                        <td>${db.contract[i].payment_day}</td>
                        <td>${db.contract[i].contract_number}</td>
                        <td>${db.contract[i].payment_period}</td>
                        <td>${db.contract[i].payment_method}</td>
                        <td>${db.contract[i].isOverdue}</td>
                        <td >${db.contract[i].contract_state}</td>
                        <td >${db.contract[i].contract_createdDate}</td>
                        <td>
                            <button class="btnModify1 btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                            <button class="btnView1 btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                            <button class="btnDelete1 btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                        </td>
                    `
                        tbody.append(tr);
                    }
                }
            })
        }
    }

    pre = document.getElementById('pre');//上一页
    next = document.getElementById('next');//下一页

    pre.onclick = function (e) {
        e.preventDefault();
        if (pageThis != 1) { //当前页数不等于1时执行上一页
            pageThis--;
            for (let j = 1; j < liAll.length - 1; j++) {
                liAll[j].childNodes[0].style.color = "#ccc"
                liAll[j].childNodes[0].style.backgroundColor = "#fff"
            }
            liAll[pageThis].childNodes[0].style.color = "#fff";
            liAll[pageThis].childNodes[0].style.backgroundColor = "#44B096"
            let start;
            let end;
            if (pageThis != 1) {
                start = (pageThis - 1) * page_number;
                end = start + page_number - 1;
                if (end > db.contract.length - 1) {
                    end = db.contract.length - 1;
                }
            } else {
                start = 0;
                end = page_number - 1;
            }

            tbody.html('');//清空原页面
            db.contract.forEach(function (item, i) {
                if (i >= start && i <= end) {
                    let tr = document.createElement("tr");
                    if (db.contract[i].contract_state == "已保存" || db.contract[i].contract_state == "已驳回" || db.contract[i].contract_state == "") {
                        tr.innerHTML = `
                        <td>${i + 1}</td>
                        <td>${db.contract[i].id}</td>
                        <td>${db.contract[i].Client_name}</td>
                        <td>${db.contract[i].payment_day}</td>
                        <td>${db.contract[i].contract_number}</td>
                        <td>${db.contract[i].payment_period}</td>
                        <td>${db.contract[i].payment_method}</td>
                        <td>${db.contract[i].isOverdue}</td>
                        <td >${db.contract[i].contract_state}</td>
                        <td >${db.contract[i].contract_createdDate}</td>
                    <td>
                        <button class="btnModify1 btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                        <button class="btnView1 btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                        <button class="btnDelete1 btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                    </td>
                `
                        tbody.append(tr);
                    }
                    else if (db.contract[i].contract_state == "待审核" || db.contract[i].contract_state == "已审核") {
                        tr.innerHTML = `
                        <td>${i + 1}</td>
                        <td>${db.contract[i].id}</td>
                        <td>${db.contract[i].Client_name}</td>
                        <td>${db.contract[i].payment_day}</td>
                        <td>${db.contract[i].contract_number}</td>
                        <td>${db.contract[i].payment_period}</td>
                        <td>${db.contract[i].payment_method}</td>
                        <td>${db.contract[i].isOverdue}</td>
                        <td >${db.contract[i].contract_state}</td>
                        <td >${db.contract[i].contract_createdDate}</td>
                        <td>
        
                            <button class="btnView1 btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
        
                        </td>
                    `
                        tbody.append(tr);
                    }
                    else {
                        tr.innerHTML = `
                        <td>${i + 1}</td>
                        <td>${db.contract[i].id}</td>
                        <td>${db.contract[i].Client_name}</td>
                        <td>${db.contract[i].payment_day}</td>
                        <td>${db.contract[i].contract_number}</td>
                        <td>${db.contract[i].payment_period}</td>
                        <td>${db.contract[i].payment_method}</td>
                        <td>${db.contract[i].isOverdue}</td>
                        <td >${db.contract[i].contract_state}</td>
                        <td >${db.contract[i].contract_createdDate}</td>
                        <td>
                            <button class="btnModify1 btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                            <button class="btnView1 btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                            <button class="btnDelete1 btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                        </td>
                    `
                        tbody.append(tr);
                    }
                }
            })
        }
    }

    next.onclick = function (e) {
        e.preventDefault();
        if (pageThis < liAll.length - 2) { //当前页数小于最后一页则执行下一页
            pageThis++;
            for (var j = 1; j < liAll.length - 1; j++) {
                liAll[j].childNodes[0].style.color = "#ccc"
                liAll[j].childNodes[0].style.backgroundColor = "#fff"
            }
            liAll[pageThis].childNodes[0].style.color = "#fff";
            liAll[pageThis].childNodes[0].style.backgroundColor = "#44B096"
            let start;
            let end;
            if (pageThis != 1) {
                start = (pageThis - 1) * page_number;
                end = start + page_number - 1;
                if (end > db.contract.length - 1) {
                    end = db.contract.length - 1;
                }
            } else {
                start = 0;
                end = page_number - 1;
            }

            tbody.html('');//清空原页面
            db.contract.forEach(function (item, i) {
                if (i >= start && i <= end) {
                    var tr = document.createElement("tr");
                    if (db.contract[i].contract_state == "已保存" || db.contract[i].contract_state == "已驳回" || db.contract[i].contract_state == "") {
                        tr.innerHTML = `
                        <td>${i + 1}</td>
                        <td>${db.contract[i].id}</td>
                        <td>${db.contract[i].Client_name}</td>
                        <td>${db.contract[i].payment_day}</td>
                        <td>${db.contract[i].contract_number}</td>
                        <td>${db.contract[i].payment_period}</td>
                        <td>${db.contract[i].payment_method}</td>
                        <td>${db.contract[i].isOverdue}</td>
                        <td >${db.contract[i].contract_state}</td>
                        <td >${db.contract[i].contract_createdDate}</td>
                    <td>
                        <button class="btnModify1 btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                        <button class="btnView1 btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                        <button class="btnDelete1 btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                    </td>
                `
                        tbody.append(tr);
                    }
                    else if (db.contract[i].contract_state == "待审核" || db.contract[i].contract_state == "已审核") {
                        tr.innerHTML = `
                        <td>${i + 1}</td>
                        <td>${db.contract[i].id}</td>
                        <td>${db.contract[i].Client_name}</td>
                        <td>${db.contract[i].payment_day}</td>
                        <td>${db.contract[i].contract_number}</td>
                        <td>${db.contract[i].payment_period}</td>
                        <td>${db.contract[i].payment_method}</td>
                        <td>${db.contract[i].isOverdue}</td>
                        <td>${db.contract[i].contract_state}</td>
                        <td>${db.contract[i].contract_createdDate}</td>
                        <td>
        
                            <button class="btnView1 btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
        
                        </td>
                    `
                        tbody.append(tr);
                    }
                    else {
                        tr.innerHTML = `
                        <td>${i + 1}</td>
                        <td>${db.contract[i].id}</td>
                        <td>${db.contract[i].Client_name}</td>
                        <td>${db.contract[i].payment_day}</td>
                        <td>${db.contract[i].contract_number}</td>
                        <td>${db.contract[i].payment_period}</td>
                        <td>${db.contract[i].payment_method}</td>
                        <td>${db.contract[i].isOverdue}</td>
                        <td>${db.contract[i].contract_state}</td>
                        <td>${db.contract[i].contract_createdDate}</td>
                        <td>
                            <button class="btnModify1 btn1" name="change" data-index='${db.contract[i].id}'>编辑</button>
                            <button class="btnView1 btn1" name="ck" data-index='${db.contract[i].id}'>查看</button>
                            <button class="btnDelete1 btn1" name="del" data-index='${db.contract[i].id}'>删除</button>
                        </td>
                    `
                        tbody.append(tr);
                    }
                }
            })
        }
    }
}




//查询分页22222
function displayContractData1() {//初始化合同记录的数据
    let table = document.getElementById('table1')
    let ul = document.getElementById('pagination');
    let page_number = 5; //单页浏览的条数
    let Total_pages = 1; //页数
    let liAll; //页码按钮下标为 1到length-2是页数 0和length-1为上一页和下一页
    let pre; //上一页
    let next; //下一页
    let tbody = $('#DataShow');
    tbody.html('');//清空原页面
    ul.innerHTML = '';
    arr5.forEach(function (item, i) {
        //当下标小于页面展示的数据
        if (i < page_number) {
            let tr = document.createElement("tr");
            if (arr5[i].contract_state == "已保存" || arr5[i].contract_state == "已驳回" || arr5[i].contract_state == "") {
                tr.innerHTML = `
            <td name="id">${i + 1}</td>
            <td name="contract_number">${arr5[i].contract_number}</td>
            <td name="contract_name">${arr5[i].contract_name}</td>
            <td name="Client_name">${arr5[i].Client_name}</td>
            <td name="contract_day">${arr5[i].contract_day}</td>
            <td name="contract_amount">${arr5[i].contract_amount}</td>
            <td name="payment_amount">${arr5[i].payment_amount}</td>
            <td name="contract_state">${arr5[i].contract_state}</td>
            <td name="contract_createdDate">${arr5[i].contract_createdDate}</td>
            <td>
                <button class="btnModify btn1" name="change" data-index='${arr5[i].id}'>编辑</button>
                <button class="btnView btn1" name="ck" data-index='${arr5[i].id}'>查看</button>
                <button class="btnDelete btn1" name="del" data-index='${arr5[i].id}'>删除</button>
            </td>
        `
                tbody.append(tr);
            }
            else if (arr5[i].contract_state == "待审核" || arr5[i].contract_state == "已审核") {
                tr.innerHTML = `
                <td name="id">${i + 1}</td>
                <td name="contract_number">${arr5[i].contract_number}</td>
                <td name="contract_name">${arr5[i].contract_name}</td>
                <td name="Client_name">${arr5[i].Client_name}</td>
                <td name="contract_day">${arr5[i].contract_day}</td>
                <td name="contract_amount">${arr5[i].contract_amount}</td>
                <td name="payment_amount">${arr5[i].payment_amount}</td>
                <td name="contract_state">${arr5[i].contract_state}</td>
                <td name="contract_createdDate">${arr5[i].contract_createdDate}</td>
                <td>

                    <button class="btnView btn1" name="ck" data-index='${arr5[i].id}'>查看</button>

                </td>
            `
                tbody.append(tr);
            }
            else {
                tr.innerHTML = `
                <td name="id">${i + 1}</td>
                <td name="contract_number">${arr5[i].contract_number}</td>
                <td name="contract_name">${arr5[i].contract_name}</td>
                <td name="Client_name">${arr5[i].Client_name}</td>
                <td name="contract_day">${arr5[i].contract_day}</td>
                <td name="contract_amount">${arr5[i].contract_amount}</td>
                <td name="payment_amount">${arr5[i].payment_amount}</td>
                <td name="contract_state">${arr5[i].contract_state}</td>
                <td name="contract_createdDate">${arr5[i].contract_createdDate}</td>
                <td>
                    <button class="btnModify btn1" name="change" data-index='${arr5[i].id}'>编辑</button>
                    <button class="btnView btn1" name="ck" data-index='${arr5[i].id}'>查看</button>
                    <button class="btnDelete btn1" name="del" data-index='${arr5[i].id}'>删除</button>
                </td>
            `
                tbody.append(tr);
            }

        }
    })
    let len = arr5.length; //记录总条数
    // console.log(len);
    let TotalArr = len % page_number == 0 ? len / page_number : len / page_number + 1; //页数

    ul.innerHTML += `
        <li id="pre">
            <a href="#">
                <span aria-hidden="true">&lt;</span>
            </a>
        </li>
    `
    //根据页面数量来创建下标
    for (let i = 1; i <= TotalArr; i++) {
        ul.innerHTML += `
        <li id="${i}"><a href="#javascript">${i}</a></li>
    `
    }
    ul.innerHTML += `
        <li id="next">
            <a href="#javascript"  aria-label="Next">
                <span aria-hidden="true">&gt;</span>
            </a>    
        </li>
    `
    liAll = document.querySelectorAll('#pagination li');
    liAll[1].childNodes[0].style.color = '#fff' //初识第一页页码是红的
    liAll[1].childNodes[0].style.backgroundColor = '#44B096'
    let pageThis = 1; //当前是第几页
    for (let i = 1; i < liAll.length - 1; i++) { //0和length-1是上一页下一页
        liAll[i].onclick = function () {
            for (let j = 1; j < liAll.length - 1; j++) {
                liAll[j].childNodes[0].style.color = "#ccc"
                liAll[j].childNodes[0].style.backgroundColor = "#fff"


            }
            pageThis = this.id;
            // console.log(pageThis);
            liAll[pageThis].childNodes[0].style.color = "#fff";
            liAll[pageThis].childNodes[0].style.backgroundColor = "#44B096"

            let start;//当前数据的起始下标
            let end;//当前数据的结束下标

            if (pageThis != 1) {
                start = (pageThis - 1) * page_number;
                end = start + page_number - 1;
                if (end > arr5.length - 1) {//如果当页面数据结束值大于总数据条数下标的值则赋值为总数据条数最大下标值。
                    end = arr5.length - 1
                }
            }
            else {
                start = 0;
                end = page_number - 1;
            }
            tbody.html('');//清空原页面

            arr5.forEach(function (item, i) {
                if (i >= start && i <= end) {
                    let tr = document.createElement('tr');
                    if (arr5[i].contract_state == "已保存" || arr5[i].contract_state == "已驳回" || arr5[i].contract_state == "") {
                        tr.innerHTML = `
                    <td name="id">${i + 1}</td>
                    <td name="contract_number">${arr5[i].contract_number}</td>
                    <td name="contract_name">${arr5[i].contract_name}</td>
                    <td name="Client_name">${arr5[i].Client_name}</td>
                    <td name="contract_day">${arr5[i].contract_day}</td>
                    <td name="contract_amount">${arr5[i].contract_amount}</td>
                    <td name="payment_amount">${arr5[i].payment_amount}</td>
                    <td name="contract_state">${arr5[i].contract_state}</td>
                    <td name="contract_createdDate">${arr5[i].contract_createdDate}</td>
                    <td>
                        <button class="btnModify btn1" name="change" data-index='${arr5[i].id}'>编辑</button>
                        <button class="btnView btn1" name="ck" data-index='${arr5[i].id}'>查看</button>
                        <button class="btnDelete btn1" name="del" data-index='${arr5[i].id}'>删除</button>
                    </td>
                `
                        tbody.append(tr);
                    }
                    else if (arr5[i].contract_state == "待审核" || arr5[i].contract_state == "已审核") {
                        tr.innerHTML = `
                        <td name="id">${i + 1}</td>
                        <td name="contract_number">${arr5[i].contract_number}</td>
                        <td name="contract_name">${arr5[i].contract_name}</td>
                        <td name="Client_name">${arr5[i].Client_name}</td>
                        <td name="contract_day">${arr5[i].contract_day}</td>
                        <td name="contract_amount">${arr5[i].contract_amount}</td>
                        <td name="payment_amount">${arr5[i].payment_amount}</td>
                        <td name="contract_state">${arr5[i].contract_state}</td>
                        <td name="contract_createdDate">${arr5[i].contract_createdDate}</td>
                        <td>
        
                            <button class="btnView btn1" name="ck" data-index='${arr5[i].id}'>查看</button>
        
                        </td>
                    `
                        tbody.append(tr);
                    }
                    else {
                        tr.innerHTML = `
                        <td name="id">${i + 1}</td>
                        <td name="contract_number">${arr5[i].contract_number}</td>
                        <td name="contract_name">${arr5[i].contract_name}</td>
                        <td name="Client_name">${arr5[i].Client_name}</td>
                        <td name="contract_day">${arr5[i].contract_day}</td>
                        <td name="contract_amount">${arr5[i].contract_amount}</td>
                        <td name="payment_amount">${arr5[i].payment_amount}</td>
                        <td name="contract_state">${arr5[i].contract_state}</td>
                        <td name="contract_createdDate">${arr5[i].contract_createdDate}</td>
                        <td>
                            <button class="btnModify btn1" name="change" data-index='${arr5[i].id}'>编辑</button>
                            <button class="btnView btn1" name="ck" data-index='${arr5[i].id}'>查看</button>
                            <button class="btnDelete btn1" name="del" data-index='${arr5[i].id}'>删除</button>
                        </td>
                    `
                        tbody.append(tr);
                    }
                }
            })
        }
    }

    pre = document.getElementById('pre');//上一页
    next = document.getElementById('next');//下一页

    pre.onclick = function (e) {
        e.preventDefault();
        if (pageThis != 1) { //当前页数不等于1时执行上一页
            pageThis--;
            for (let j = 1; j < liAll.length - 1; j++) {
                liAll[j].childNodes[0].style.color = "#ccc"
                liAll[j].childNodes[0].style.backgroundColor = "#fff";

            }
            liAll[pageThis].childNodes[0].style.color = "#fff";
            liAll[pageThis].childNodes[0].style.backgroundColor = "#44B096";
            let start;
            let end;
            if (pageThis != 1) {
                start = (pageThis - 1) * page_number;
                end = start + page_number - 1;
                if (end > arr5.length - 1) {
                    end = arr5.length - 1;
                }
            } else {
                start = 0;
                end = page_number - 1;
            }

            tbody.html('');//清空原页面
            arr5.forEach(function (item, i) {
                if (i >= start && i <= end) {
                    let tr = document.createElement("tr");
                    if (arr5[i].contract_state == "已保存" || arr5[i].contract_state == "已驳回" || arr5[i].contract_state == "") {
                        tr.innerHTML = `
                    <td name="id">${i + 1}</td>
                    <td name="contract_number">${arr5[i].contract_number}</td>
                    <td name="contract_name">${arr5[i].contract_name}</td>
                    <td name="Client_name">${arr5[i].Client_name}</td>
                    <td name="contract_day">${arr5[i].contract_day}</td>
                    <td name="contract_amount">${arr5[i].contract_amount}</td>
                    <td name="payment_amount">${arr5[i].payment_amount}</td>
                    <td name="contract_state">${arr5[i].contract_state}</td>
                    <td name="contract_createdDate">${arr5[i].contract_createdDate}</td>
                    <td>
                        <button class="btnModify btn1" name="change" data-index='${arr5[i].id}'>编辑</button>
                        <button class="btnView btn1" name="ck" data-index='${arr5[i].id}'>查看</button>
                        <button class="btnDelete btn1" name="del" data-index='${arr5[i].id}'>删除</button>
                    </td>
                `
                        tbody.append(tr);
                    }
                    else if (arr5[i].contract_state == "待审核" || arr5[i].contract_state == "已审核") {
                        tr.innerHTML = `
                        <td name="id">${i + 1}</td>
                        <td name="contract_number">${arr5[i].contract_number}</td>
                        <td name="contract_name">${arr5[i].contract_name}</td>
                        <td name="Client_name">${arr5[i].Client_name}</td>
                        <td name="contract_day">${arr5[i].contract_day}</td>
                        <td name="contract_amount">${arr5[i].contract_amount}</td>
                        <td name="payment_amount">${arr5[i].payment_amount}</td>
                        <td name="contract_state">${arr5[i].contract_state}</td>
                        <td name="contract_createdDate">${arr5[i].contract_createdDate}</td>
                        <td>
        
                            <button class="btnView btn1" name="ck" data-index='${arr5[i].id}'>查看</button>
        
                        </td>
                    `
                        tbody.append(tr);
                    }
                    else {
                        tr.innerHTML = `
                        <td name="id">${i + 1}</td>
                        <td name="contract_number">${arr5[i].contract_number}</td>
                        <td name="contract_name">${arr5[i].contract_name}</td>
                        <td name="Client_name">${arr5[i].Client_name}</td>
                        <td name="contract_day">${arr5[i].contract_day}</td>
                        <td name="contract_amount">${arr5[i].contract_amount}</td>
                        <td name="payment_amount">${arr5[i].payment_amount}</td>
                        <td name="contract_state">${arr5[i].contract_state}</td>
                        <td name="contract_createdDate">${arr5[i].contract_createdDate}</td>
                        <td>
                            <button class="btnModify btn1" name="change" data-index='${arr5[i].id}'>编辑</button>
                            <button class="btnView btn1" name="ck" data-index='${arr5[i].id}'>查看</button>
                            <button class="btnDelete btn1" name="del" data-index='${arr5[i].id}'>删除</button>
                        </td>
                    `
                        tbody.append(tr);
                    }
                }
            })
        }
    }

    next.onclick = function (e) {
        e.preventDefault();
        if (pageThis < liAll.length - 2) { //当前页数小于最后一页则执行下一页
            pageThis++;
            for (var j = 1; j < liAll.length - 1; j++) {
                liAll[j].childNodes[0].style.color = "blue"
            }
            liAll[pageThis].childNodes[0].style.color = "red";
            let start;
            let end;
            if (pageThis != 1) {
                start = (pageThis - 1) * page_number;
                end = start + page_number - 1;
                if (end > arr5.length - 1) {
                    end = arr5.length - 1;
                }
            } else {
                start = 0;
                end = page_number - 1;
            }

            tbody.html('');//清空原页面
            arr5.forEach(function (item, i) {
                if (i >= start && i <= end) {
                    var tr = document.createElement("tr");
                    if (arr5[i].contract_state == "已保存" || arr5[i].contract_state == "已驳回" || arr5[i].contract_state == "") {
                        tr.innerHTML = `
                    <td name="id">${i + 1}</td>
                    <td name="contract_number">${arr5[i].contract_number}</td>
                    <td name="contract_name">${arr5[i].contract_name}</td>
                    <td name="Client_name">${arr5[i].Client_name}</td>
                    <td name="contract_day">${arr5[i].contract_day}</td>
                    <td name="contract_amount">${arr5[i].contract_amount}</td>
                    <td name="payment_amount">${arr5[i].payment_amount}</td>
                    <td name="contract_state">${arr5[i].contract_state}</td>
                    <td name="contract_createdDate">${arr5[i].contract_createdDate}</td>
                    <td>
                        <button class="btnModify btn1" name="change" data-index='${arr5[i].id}'>编辑</button>
                        <button class="btnView btn1" name="ck" data-index='${arr5[i].id}'>查看</button>
                        <button class="btnDelete btn1" name="del" data-index='${arr5[i].id}'>删除</button>
                    </td>
                `
                        tbody.append(tr);
                    }
                    else if (arr5[i].contract_state == "待审核" || arr5[i].contract_state == "已审核") {
                        tr.innerHTML = `
                        <td name="id">${i + 1}</td>
                        <td name="contract_number">${arr5[i].contract_number}</td>
                        <td name="contract_name">${arr5[i].contract_name}</td>
                        <td name="Client_name">${arr5[i].Client_name}</td>
                        <td name="contract_day">${arr5[i].contract_day}</td>
                        <td name="contract_amount">${arr5[i].contract_amount}</td>
                        <td name="payment_amount">${arr5[i].payment_amount}</td>
                        <td name="contract_state">${arr5[i].contract_state}</td>
                        <td name="contract_createdDate">${arr5[i].contract_createdDate}</td>
                        <td>
        
                            <button class="btnView btn1" name="ck" data-index='${arr5[i].id}'>查看</button>
        
                        </td>
                    `
                        tbody.append(tr);
                    }
                    else {
                        tr.innerHTML = `
                        <td name="id">${i + 1}</td>
                        <td name="contract_number">${arr5[i].contract_number}</td>
                        <td name="contract_name">${arr5[i].contract_name}</td>
                        <td name="Client_name">${arr5[i].Client_name}</td>
                        <td name="contract_day">${arr5[i].contract_day}</td>
                        <td name="contract_amount">${arr5[i].contract_amount}</td>
                        <td name="payment_amount">${arr5[i].payment_amount}</td>
                        <td name="contract_state">${arr5[i].contract_state}</td>
                        <td name="contract_createdDate">${arr5[i].contract_createdDate}</td>
                        <td>
                            <button class="btnModify btn1" name="change" data-index='${arr5[i].id}'>编辑</button>
                            <button class="btnView btn1" name="ck" data-index='${arr5[i].id}'>查看</button>
                            <button class="btnDelete btn1" name="del" data-index='${arr5[i].id}'>删除</button>
                        </td>
                    `
                        tbody.append(tr);
                    }
                }
            })
        }
    }
}





